package cn.itcast.config;

import com.mchange.v2.c3p0.ComboPooledDataSource;
import org.apache.commons.dbutils.QueryRunner;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;

import javax.sql.DataSource;
import java.beans.PropertyVetoException;

@Configuration
//进行注解包扫描
@ComponentScan("cn.itcast")
@Import(ConfigA.class)
public class Config {
    //将DataSource载入到容器;
  /*  @Bean
    public DataSource getDataSource() throws PropertyVetoException {
        ComboPooledDataSource ds = new ComboPooledDataSource();
         ds.setDriverClass("com.mysql.jdbc.Driver");
         ds.setJdbcUrl("jdbc:mysql:///db1");
         ds.setPassword("root");
         ds.setUser("root");

        return ds;

    }
*/
    //queryRunner载入到容器
    //@Bean
    public QueryRunner getRunner(@Qualifier("getDataSource2") DataSource ds) {

        return new QueryRunner(ds);
    }

}
